SOURCE		:=	src src/audio src/cdrom src/cpuinfo src/events src/file src/joystick src/stdlib src/thread src/timer src/video src/audio/cell src/video/cell src/video/cell/input src/cdrom/dummy src/thread/pthread src/timer/cell src/loadso/dummy src/joystick/cell
INCLUDE		:=	include

###
export PATH := $(CELL_SDK)/host-win32/bin:$(CELL_SDK)/host-win32/sn/bin:$(PATH)

.SUFFIXES:

AS			:=	ps3ppuas
CC			:=	ps3ppusnc
CXX			:=	ps3ppusnc
AR			:=	ps3snarl
CFLAGS		+= -O2 -DDECLSPEC=" " -g --std=gnu99 -DPSGL -O2

#CELL_OSK_CAPTION: Display the window manager caption along the top of the screen when the OSK is visible
#			Requires freetype2 and SDL_ttf. Disable to avoid the bloat if it's not useful
#CFLAGS		+= -DCELL_OSK_CAPTION

#CELL_SHADER_SUPPORT: Enable shader support, requires addition memory
#CFLAGS		+= -DCELL_SHADER_SUPPORT


###

#RULES FOR COMPILE
%.o: %.c
	@echo "[CC]  $(notdir $<)"
	@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

%.o: %.cpp
	@echo "[CXX] $(notdir $<)"
	@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

#Update this!
#%.o: %.S
#	@echo "[CC]  $(notdir $<)"
#	@$(CC) $(DEPSOPTIONS) -x assembler-with-cpp $(ASFLAGS) $(INCLUDES) -c $< -o $@

%.a:
	@echo "[AR]  $(notdir $@)"
	@$(AR) -rcs libsdl.a $^

################

CFILES		+= $(foreach dir,$(SOURCE),$(wildcard $(dir)/*.c))
CXXFILES	+= $(foreach dir,$(SOURCE),$(wildcard $(dir)/*.cpp))
SFILES		+= $(foreach dir,$(SOURCE),$(wildcard $(dir)/*.S))

export OFILES	:=	$(CFILES:.c=.o) $(CXXFILES:.cpp=.o) $(SFILES:.S=.o) 
export INCLUDES	:=	$(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) -I$(CURDIR)/$(BUILD)

.PHONY: clean

#$(BUILD):
#	@[ -d $@ ] || mkdir -p $@
#	@$(MAKE) --no-print-directory -C $(BUILD)-$(PLATFORM) -f $(CURDIR)/Makefile

libsdl.a: $(OFILES)
clean:
	@echo Clean...
	@rm -rf libsdl.a $(OFILES)



DEPENDS	:= $(OFILES:.o=.d)

-include $(DEPENDS)


